import logging
import redis

# 配置信息
class Config(object):

    DEBUG = True
    # 设置秘钥
    SECRET_KEY = "davavaeaeva"

    #数据库配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information10"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True #当数据库内容发生变化后,在视图函数结束后会自动提交
    #配置redis
    REDIS_HOST = "127.0.0.1"
    REDIS_POST = 6379

    # 配置session信息
    # config.setdefault('SESSION_TYPE', 'null')
    # config.setdefault('SESSION_PERMANENT', True)
    # config.setdefault('SESSION_USE_SIGNER', False)
    # config.setdefault('SESSION_KEY_PREFIX', 'session:')
    # config.setdefault('SESSION_REDIS', None)
    # config.setdefault('SESSION_MEMCACHED', None)
    SESSION_TYPE = "redis"
    SESSION_USE_SIGNER = "Ture"
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST,port=REDIS_POST)
    PERMANENT_SESSION_LIFETIME = 3600*24*2  #两天有效
# 默认调试级别
    LEVEL = logging.DEBUG
# 开发环境
class DevelopConfig(Config):
    pass

# 生产环境
class ProductConfig(Config):
    DEBUG = False

    LEVEL = logging.ERROR

# 测试环境
class TestConfig(Config):
    TESTING = True

config_dict = {
    "develop" : DevelopConfig,
    "product" : ProductConfig,
    "testing" : TestConfig
 }